package com.hippoDocker.nacosorder.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @ClassName PaymentController
 * @Description TODO
 * @Author hippoDocker
 * @Date 2022/6/1 16:56
 **/
@RestController
@RequestMapping("/consumer")
@Slf4j
public class OrderNacosController {
    @Resource
    private RestTemplate restTemplate;

    @Value("${service-url.nacos-user-service}")
    private String paymentUrl;

    @GetMapping("/nacos/{id}")
    public String createPayment(@PathVariable("id") Integer id) {
        log.info(paymentUrl + "/payment/nacos/"+id);
        return restTemplate.getForObject(paymentUrl + "/payment/nacos/"+id, String.class);
    }
}
